package com.ynny.librarysystemmanager.mapper;

import com.github.pagehelper.PageInfo;
import com.ynny.librarysystemmanager.entity.Record;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RecordMapper {

    // 插入一条借阅记录
    int insertRecord(Record Record);

    // 根据ID查询借阅记录
    Record selectRecordById(Integer id);

    // 查询所有借阅记录
    List<Record> selectAllRecords(Record record);


    // 更新借阅记录
    int updateRecord(Record Record);

    // 删除借阅记录
    int deleteRecordById(Integer id);

    Record selectRecordByUserIdAndBookId(@Param("userId") Integer userId,
                                         @Param("bookId") Integer bookId);

    @Select("""
        SELECT *
        FROM record
        WHERE
        end_time <= NOW() 
        AND `status` != 3 
""")
    List<Record> selectRecordsLessEndTime();
}
